<template>
  <div>
    <form action="/">
      <van-search
        v-model="searchValue"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
  </div>
</template>

<script>
  import { Toast } from "vant";
  export default {
    name: "CommonSearch",
    data () {
      return {
        searchValue: '',
      }
    },
    mounted() {
      this.$nextTick(() => {
        try {
          const input = document.getElementsByClassName(
            "van-field__control"
          )[1];

          input.focus();
        } catch (e) {}
      });
    },
    methods: {
      onSearch(val) {
        Toast(val);
      },
      onCancel() {
        this.$router.go(-1);
      },
    }
  }
</script>

<style scoped>

</style>